#encoding: utf-8
from turtle import *
import turtle

length = 2
angle = 60
speed(0)

rules = {
    "Fl": "Fl+Fr+",
    "Fr": "-Fl-Fr"
}
def split_path(path):
    i  = 0
    lst = []
    while i < len(path):
        if path[i] == "F":
            lst.append(path[i:i+2])
            i= i + 2
        else:
            lst.append(path[i])
            i= i+1

    return lst

def apply_role(path, rules):
    lst = split_path(path)

    for i in range(len(lst)):
        sym = lst[i]

        if sym in rules:
            lst[i] = rules[sym]
        else:
            pass

    path = "".join(symbol  for symbol in lst)

    return path


def draw_path(path):
    lst = split_path(path)
    for sym in lst:
        if sym =="Fr" or sym=="Fl":
            forward(length)
        elif sym == "-":
            left(angle)
        elif sym =="+":
            right(angle)



path = "Fl+Fr+"

for i in range(10):
    path = apply_role(path, rules)

draw_path(path)

turtle.done()  #